<template>
  <el-form
    ref="ruleFormRef"
    style="max-width: 600px"
    :model="ruleForm"
    status-icon
    label-width="auto"
    class="demo-ruleForm"
  >
    <el-form-item label="Password" prop="pass">
      <el-input v-model="ruleForm.from" />
    </el-form-item>
    <el-form-item label="Confirm" prop="checkPass">
      <el-input v-model="ruleForm.to" />
    </el-form-item>
    <el-form-item label="Age" prop="age">
      <el-input v-model.number="ruleForm.amount" />
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="submitForm()">Submit</el-button>
      <el-button @click="resetForm(ruleFormRef)">Reset</el-button>
    </el-form-item>
  </el-form>
</template>

<script lang="ts" setup>
import { ref } from 'vue'
import type { FormInstance } from 'element-plus'
import {
  getCarbonEmission, getEmission,
  quotaShare,
  transferCarbonCoin,
  transferToIntermediaries
} from '@/utils/useWeb3'

const ruleFormRef = ref<FormInstance>()

const ruleForm = ref({
  from: '',
  to: '',
  amount: ''
})

const submitForm = async () => {
  // const res = await transferCarbonCoin(ruleForm.value.from,ruleForm.value.to,ruleForm.value.amount)
  // console.log(res)
//await getCarbonEmission(ruleForm.value.from, ruleForm.value.to)
  const res =await getEmission(ruleForm.value.from) //await transferToIntermediaries(ruleForm.value.to,ruleForm.value.amount)//await quotaShare(ruleForm.value.from, ruleForm.value.to, ruleForm.value.amount)
  console.log(res.emission)
  console.log(Number.parseInt(123.223))
}

const resetForm = (formEl: FormInstance | undefined) => {}
</script>
